//
//  ConfigManager.h
//  BayMaxPuzzle
//
//  Created by Jacky on 15/3/29.
//
//

#ifndef __BayMaxPuzzle__ConfigManager__
#define __BayMaxPuzzle__ConfigManager__

#include "cocos2d.h"
#include "Global.h"

USING_NS_CC;

class ConfigManager
{
public:
    
    static ConfigManager* getInstance()
    {
        if ( m_pInstance == nullptr )
            m_pInstance = new ConfigManager();
        return m_pInstance;
    }
    
private:
    
    ConfigManager();
    
    static ConfigManager* m_pInstance;
    
    class CGarbo
    {
    public:
        ~CGarbo()
        {
            if (ConfigManager::m_pInstance!= nullptr)
            {
                delete ConfigManager::m_pInstance;
            }
        }
    };
    
    static CGarbo m_garbo;
    
    int _score[CHAPTER][SECTION];
    
public:
    
    bool isHaveSaveFile();
    void readConfig();
    void initConfig();
    void saveConfig();
    
    int getConfig(int chapter, int section);
    void setConfig(int chapter, int section, int score);
    void dumpAllConfig();
};
#endif /* defined(__BayMaxPuzzle__ConfigManager__) */
